﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Chefbook.DataObjects;
using Chefbook.ViewModels;

namespace UnitTests.ViewModelsTests
{
    [TestFixture]
    public class IngredientViewModelFixture
    {
        private IngredientViewModel ingredientVM;
        private Ingredient ingredient;

        [SetUp]
        public void Init()
        {
            ingredient = new Ingredient();
            ingredientVM = new IngredientViewModel(ingredient);
            ingredientVM.Amount = 3.5f;
            ingredientVM.Name = "Bacon";
            ingredientVM.Units = "Lbs";
        }

        [Test]
        public void AmountChangeTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Amount = 2.5f, "Amount");
        }

        [Test]
        public void AmountChangeDidntFireTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Amount = 3.5f);
        }

        [Test]
        public void NameChangeTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Name = "Beef", "Name");
        }

        [Test]
        public void NameChangeDidntFireTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Name = "Bacon");
        }

        [Test]
        public void UnitsChangeTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Units = "Oz", "Units");
        }

        [Test]
        public void UnitsChangeDidntFireTest()
        {
            ingredientVM.AssertPropertyChangedFired(() => ingredientVM.Units = "Lbs");
        }

        [Test]
        public void AssertRemovedEventFired()
        {
            bool eventFired = false;
            ingredientVM.IngredientDeleted += (s, e) => eventFired = true;
            ingredientVM.RemoveIngredientCommand.Execute(new object());
            Assert.That(eventFired);
        }
    }
}